import { BASEURL } from './const.js'
const BaseUrl = BASEURL
const uploadFile = (path, data, header = {}) => {
	// 请求头
	header = {
		...header,
		'Content-Type': 'application/json',
	}
	
	let formData = data.data || {}
	console.log(data)
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: BaseUrl + path,
			filePath: data.file,
			name: data.name,
			header: header,
			timeout: 20000,
			formData: formData,
			success: (res) => {
				resolve(JSON.parse(res.data))
			},
			fail: (err) => {
				reject(err)
			},
			complete: (com) => {
			}
		})
	})
}

export default uploadFile